Skip to content

Conversation

compiler-errors
Copy link
Member

This is Rust, not Java! Returns are not necessary unless they interrupt control flow!

Fixes instances of clippy::needless_return. This is especially jarring when it's paired with match branches that do not return, like:

if whatever {
    return Some(x);
} else {
    None
}

or

match whatever {
    Variant => true,
    OtherVariant => return false,
}

... since it suggests that some exceptional control flow is happening even though it isn't.

I also tried to turn some:

if whatever {
    side_effect();
    return true;
}
return false;

into:

if whatever {
    side_effect();
    true
} else {
    false
}

Though I only did it when I noticed it.

@rustbot
Copy link
Collaborator

rustbot commented Sep 11, 2024

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 11, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 11, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Sep 11, 2024
@compiler-errors compiler-errors added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Sep 11, 2024
@RalfJung
Copy link
Member

Duplicate of #130114?

@compiler-errors
Copy link
Member Author

Yep! Glad that's getting fixed lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants